<% layout('/layout/default.html', {title: '流程模型管理', libs: ['dataGrid']}){ %>
<div class="main-content">
  <div class="box box-main">
    <div class="box-header">
      <div class="box-title">
        <i class="fa fa-cubes"></i> 流程模型管理
      </div>
      <div class="box-tools pull-right">
        <a class="btn btn-default" href="#" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
        <% if(hasPermi('act:model:edit')){ %>
        <a class="btn btn-default btnTool" data-type="layer" href="${ctxStatic}/modler/index.html#/processes"
           title="新增流程模型"><i class="fa fa-plus"></i> 新增</a>
        <% } %>
      </div>
    </div>
    <div class="box-body">
      <form action="${ctx}/act/model/listData" class="form-inline hide" id="searchForm" method="post">

        <div class="form-group">
          <label class="control-label">模型标识KEY：</label>
          <div class="control-inline">
            <input class="form-control" maxlength="100" name="key"/>
          </div>
        </div>
        <div class="form-group">
          <label class="control-label">模型名称：</label>
          <div class="control-inline">
            <input class="form-control" maxlength="100" name="name"/>
          </div>
        </div>

        <div class="form-group">
          <button class="btn btn-primary btn-sm" type="submit">查询</button>
          <button class="btn btn-default btn-sm" type="reset">重置</button>
        </div>
      </form>
      <table id="dataGrid"></table>
      <div id="dataGridPage"></div>
    </div>
  </div>
</div>
<% } %>
<script>
    //初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        columnModel: [
            {header: '模型ID', name: 'id', index: 'a.id', width: 90, align: "center"},
            {header: '模型标识KEY', name: 'key', index: 'a.model_key', width: 100, align: "center"},
            {header: '模型名称', name: 'name', index: 'a.name', width: 100, align: "center"},
            {
                header: '版本号',
                name: 'version',
                index: 'a.version',
                width: 80,
                align: "center",
                formatter: function (val, obj, row, act) {
                    return "V:" + val;
                }
            },
            {header: '创建时间', name: 'created', index: 'a.created', width: 100, align: "center", formatter: "date"},
            {
                header: '最后更新时间',
                name: 'lastUpdated',
                index: 'a.last_updated',
                width: 100,
                align: "center",
                formatter: "date"
            },
            {
                header: '操作',
                name: 'actions',
                width: 100,
                sortable: false,
                title: false,
                align: "center",
                formatter: function (val, obj, row, act) {
                    var actions = [];
                <%
                    if (hasPermi('act:model:edit')) { %>

                        actions.push('<a href="${ctxStatic}/modler/index.html#/editor/' + row.id + '" class="btnList" title="流程模型编辑" data-type="layer"><i class="fa fa-pencil"></i></a>&nbsp;');
                        actions.push('<a href="${ctx}/act/model/deploy?id=' + row.id + '" class="btnList" title="部署" data-formtitle="流程分类" data-type="form" data-formurl="${ctx}/act/model/choose/category"><i class="fa fa-bolt"></i></a>&nbsp;');
                        actions.push('<a href="${flow}/app/rest/models/' + row.id + '/bpmn20' + '" title="下载" ><i class="fa fa-download"></i></a>&nbsp;');
                        actions.push('<a href="${ctx}/act/model/delete?id=' + row.id + '" class="btnList" title="删除" data-confirm="确认要删除该模型吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');

                    <%
                    }
                %>

                    return actions.join('');
                }
            }
        ],
        // 加载成功后执行事件
        ajaxSuccess: function (data) {

        }
    });

</script>
